package com.learning.springcloudproducer.controller;

import com.learning.springcloudproducer.bean.User;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * (description)
 *
 * @author jinlong.liao on 2018/3/27
 */
@RestController
@RequestMapping("/users")
public class UserController {

    @Value("${username}")
    String username;

    @Value("${password}")
    String password;

    @GetMapping("/hi")
    public String hi(@RequestParam("str") String str) {
        return username + ":" + str;
    }

    @GetMapping
    public List<User> listUser(String ids) {
        System.out.println("test1---------" + ids + "Thread.currentThread().getName():" + Thread.currentThread().getName());
        System.out.println("ids>>>>>>>>>>>>>>>>>>>>>" + ids);
        List<User> list = new ArrayList<>();
        list.add(new User(1, "1", "1", 11));
        list.add(new User(2, "2", "2", 22));
        list.add(new User(3, "3", "3", 33));
        list.add(new User(4, "4", "4", 44));
        return list;
    }

    @GetMapping("{id}")
    public User getUser(@PathVariable Integer id) {
        return new User(id, "5", "5", 55);
    }
}
